<%--

<!------------------------------------------------------------------------------
 - Copyright 2006 CORE Solutions Limited
 - All rights reserved.
 - PROPRIETARY AND CONFIDENTIAL INFORMATION.
 - Use is subject to license terms.
 -
 - FUNCTION ID      :   ITEM_CATEGORY
 - AUTHOR           :   Alex Cheung 
 - DATE CREATE      :   2006/01/20
 - DESCRIPTION      :   a PAGE-EDIT CONTENT JSP file for the function, ITEM_CATEGORY
 -                  :   
 -                  :   
 -                  :   
 -
 - MODIFICATION HISTORY:
 - DATE         AUTHOR          VERSION NO.         COMMENT
 - -----------  --------------  ------------------  -------------------
 - 2006/01/20   Alex Cheung     1.0                 source is generated.
 - 2006/06/16   Jerry Chen      1.0                 BugZilla bug 6221
 -
 -
 -
------------------------------------------------------------------------------->

--%>
<%@ include file="/jsp/com/erp/app/common/jsp/directives_include.jsp"%>

<%@ page  import="com.erp.app.catalog.itemCategory.web.ItemCategoryAction" %>
<%@ page  import="com.erp.app.catalog.itemCategory.web.ItemCategoryRow" %>

<%@ include file="/jsp/com/erp/app/common/jsp/html_include.jsp"%>

<jsp:useBean id="itemCategoryForm" scope="session" type="com.erp.app.catalog.itemCategory.web.ItemCategoryForm" />

<%
ArrayList itemCategoryList = itemCategoryForm.getMultiRows();
pageContext.setAttribute("itemCategoryList", itemCategoryList);
rowReadOnly = false;
TableSchema ts = itemCategoryForm.getTs();
%>

<script language="javascript">

	function doLoad() {
		<%
		if (CommonUtil.nullToString((String)session.getAttribute(ProjectConstants.SESSION_ALERT_AFTER_SAVE)).equals(ProjectConstants.GENERIC_YES)) {
			session.removeAttribute(ProjectConstants.SESSION_ALERT_AFTER_SAVE);
			out.println("alert('Records saved.');");
		}
		%>
	}

	function doEditItemCategory(val) {
		document.forms[0].editItemCategory.value = val;
		doSubmit('<%=ItemCategoryAction.ACTION_EDIT_ITEM_CATEGORY%>');
	}

</script>

<body onLoad="javascript:doLoad();autofill_init();">
<html:form action="/itemCategory">

<html:hidden property="pageEvent"/>
<html:hidden property="pageMode"/>

<html:hidden property="editItemCategory"/>
<html:hidden property="pageEventSrc"/>

<table class="table_button">

<tr>
	<td>
		<chtml:button form="itemCategoryForm" pageEvent="<%=ItemCategoryAction.ACTION_EXIT%>"
			styleClass="button1"/>
		<chtml:button form="itemCategoryForm" pageEvent="<%=ItemCategoryAction.ACTION_SEARCH%>"
			styleClass="button1"/>
		<chtml:button form="itemCategoryForm" pageEvent="<%=ItemCategoryAction.ACTION_CLEAR%>"
			styleClass="button1"/>
		<chtml:button form="itemCategoryForm" pageEvent="<%=ItemCategoryAction.ACTION_ADD_ROW%>"
			styleClass="button1"/>
		<chtml:button form="itemCategoryForm" pageEvent="<%=ItemCategoryAction.ACTION_SAVE%>"
			styleClass="button1"/>
		<chtml:button form="itemCategoryForm" pageEvent="<%=ItemCategoryAction.ACTION_BACK%>"
			styleClass="button1"/>
	</td>
</tr>

<tr>
	<td>

		<table class="table_crit">

		<tr>
			<%
			webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_ITEM_LINE");
			%>
			<td class="col_label">
			<%=webLabel%>
			</td>
			<td class="col_value">
				<bean:write name="itemCategoryForm" property="srchItemLineFr" filter="true"/> - 
				<% where = " NODE_ID = " + itemCategoryForm.getSrchItemLineFr();%>
				<chtml:desc table="t_category"
					column="DESCRIPTION"
					where="<%=where%>"
				/>
			</td>
			
		</tr>
		<!--<tr>
			<%
			webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_ITEM_CATEGORY");
			%>
			<td class="col_label">
			<%=webLabel%>
			</td>
			<td class="col_value">
				<html:text property="srchItemCategoryFr" styleClass="textbox1" size="<%=srchDisplaySize%>" maxlength="<%=srchColSize%>"/>
			</td>
		</tr>-->
		<tr>
			<%
			webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_ITEM_CATEGORY_DESC");
			%>
			<td class="col_label">
			<%=webLabel%>
			</td>
			<td class="col_value">
				<html:text property="srchItemCategoryDescFr" styleClass="textbox1" size="<%=srchDisplayLongSize%>" maxlength="<%=srchColLongSize%>"/>
			</td>
		</tr>
		</table>

	</td>
</tr>

<tr>
	<td><font color='red'><html:errors/></font></td>
</tr>

<tr>
	<td class="grid_page">
	<%if(itemCategoryForm.getTotalPage() == 0 ) { %>
		&nbsp;
	<%} else { %>
	    <input type="button" value="Go" class="button1" onClick="javascript:doSubmit('<%=itemCategoryForm.ACTION_SCROLL_TO%>');" >
		Page 
		<html:text property="scrollTo" styleClass="textbox1" readonly="<%=rowReadOnly%>" maxlength="4" size="4" value="<%=String.valueOf(itemCategoryForm.getCurrentPage())%>"/>
	    of <%=itemCategoryForm.getTotalPage()%>
	<%} %>
	    <input type="button" value="|&lt;&lt;" class="button1" onClick="javascript:doSubmit('<%=ItemCategoryAction.ACTION_SCROLL_TO_FIRST_PAGE%>');" <%=itemCategoryForm.getSidx() == 0 ? "disabled" : ""%>>
		<input type="button" value="&lt;&lt;" class="button1" onClick="javascript:doSubmit('<%=ItemCategoryAction.ACTION_SCROLL_LEFT%>');" <%=itemCategoryForm.getSidx() == 0 ? "disabled" : ""%>>
		<input type="button" value="&gt;&gt;" class="button1" onClick="javascript:doSubmit('<%=ItemCategoryAction.ACTION_SCROLL_RIGHT%>');" <%=itemCategoryForm.getSidx() < Integer.parseInt(itemCategoryForm.getLastPageSidx()) ? "" : "disabled"%>>
	    <input type="button" value="&gt;&gt|" class="button1" onClick="javascript:doSubmit('<%=ItemCategoryAction.ACTION_SCROLL_TO_LAST_PAGE%>');" <%=itemCategoryForm.getSidx() < Integer.parseInt(itemCategoryForm.getLastPageSidx()) ? "" : "disabled"%>>
	</td>
</tr>

</table>


<table class="table_short_grid">

	<tr class="grid_header">
	<td class="grid_header_col" nowrap>
	   Del
	</td>
	
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_ITEM_CATEGORY");
		%>
		<td class="grid_header_col" nowrap>
			<span class="mandatory_label">
				<bean:message key="label.general.mandatory.field"/><%=webLabel%>
			</span>
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_ITEM_CATEGORY_DESC");
		%>
		<td class="grid_header_col" nowrap>
			<bean:message key="label.general.mandatory.field"/>
			<span class="mandatory_label"><%=webLabel%></span>
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_STATUS");
		%>
		<td class="grid_header_col" nowrap>
			<span class="mandatory_label">
				<bean:message key="label.general.mandatory.field"/><%=webLabel%>
			</span>
		</td>
		
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_SHOW_IN_CATALOG");
		%>
		<td class="grid_header_col" nowrap>
			<%=webLabel%>
		</td>
	</tr>

	<logic:iterate id="itemCategoryRow" name="itemCategoryList" indexId="idx" length="20" offset="<%=String.valueOf(itemCategoryForm.getSidx())%>">

	<%
		ItemCategoryRow row = (ItemCategoryRow) itemCategoryRow;
	%>

	<% if((row != null) && (CommonUtil.isEmpty(row.getIsDelete()))) {%>

	<tr <%=(idx.intValue()%2 == 0)? "class='grid_result1'": "class='grid_result2'"%>>
	  <td class="grid_header_col" nowrap>
	<chtml:button form="itemCategoryForm" pageEvent="<%=ItemCategoryAction.ACTION_DELETE_ROW%>" pageEventSrc="<%=String.valueOf(idx)%>" styleClass="button1" disabled="<%=String.valueOf(rowReadOnly)%>"/>
	</td>
		<td nowrap>
			<%
			colSize = String.valueOf(ts.getColSizeByObjectId("LBL_GRID_ITEM_CATEGORY"));
			displaySize = String.valueOf(ts.getDisplaySizeByObjectId("LBL_GRID_ITEM_CATEGORY"));
			%>
			<logic:equal name="itemCategoryRow" property="rowMode" value="<%=ProjectConstants.ROW_MODE_CREATE%>">
				<html:hidden property="categoryItemCategory" value="<%=CommonUtil.nullToString(row.getCategoryItemCategory())%>"/>< To be generated. >
			</logic:equal>
			<logic:notEqual name="itemCategoryRow" property="rowMode" value="<%=ProjectConstants.ROW_MODE_CREATE%>">
				<a href="javascript:doEditItemCategory('<%=row.getCategoryItemCategory()%>');" style="text-decoration: underline;">
					<bean:write name="itemCategoryRow" property="categoryItemCategory" filter="true"/>
				</a>
				<html:hidden property="categoryItemCategory" value="<%=CommonUtil.nullToString(row.getCategoryItemCategory())%>"/>
			</logic:notEqual>
		</td>
		<td nowrap>
			<%
			colSize = String.valueOf(ts.getColSizeByObjectId("LBL_GRID_ITEM_CATEGORY_DESC"));
			displaySize = String.valueOf(ts.getDisplaySizeByObjectId("LBL_GRID_ITEM_CATEGORY_DESC"));
			%>
			<html:text property="itemCategoryDesc" styleClass="textbox1" readonly="<%=rowReadOnly%>" size="<%=displaySize%>" maxlength="<%=colSize%>" value="<%=CommonUtil.nullToString(row.getItemCategoryDesc())%>"/>
		</td>
		<td nowrap>
			<select name="status" <%=rowReadOnly ? "disabled=\"true\"" : ""%> class="selectBox1">
				<% where = "TYPE='" + ProjectConstants.CONSTANT_TYPE_ACT_INACT + "'";%>
				<chtml:options table="T_SYS_CONSTANTS"
					valuecolumn="CONSTANT_CODE"
					textcolumn="CONSTANT_NAME"
					where= "<%=where%>"
					order="ORDER_SEQ"
					selected="<%=row.getStatus()%>" />
			</select>
		</td>	
		
		<td nowrap>
			<select name="browser" <%=rowReadOnly ? "disabled=\"true\"" : ""%> class="selectBox1">
				<% where = "TYPE='" + ProjectConstants.CONSTANT_TYPE_YES_NO + "'";%>
				<chtml:options table="T_SYS_CONSTANTS"
					valuecolumn="CONSTANT_CODE"
					textcolumn="CONSTANT_NAME"
					where= "<%=where%>"	
					order="ORDER_SEQ"
					selected="<%=row.getBrowser()%>"	/>
			</select>
		</td>			
	</tr>

	<% }else{ // end if(row != null) %>
	<html:hidden property="isDelete" value="<%=row.getIdx()%>"/>
	<html:hidden property="categoryItemCategory" value="<%=CommonUtil.nullToString(row.getCategoryItemCategory())%>"/>
	<html:hidden property="status" value="<%=CommonUtil.nullToString(row.getStatus())%>"/>
	<html:hidden property="itemCategoryDesc" value="<%=CommonUtil.nullToString(row.getItemCategoryDesc())%>"/>
	<html:hidden property="browser" value="<%=CommonUtil.nullToString(row.getBrowser())%>"/>
	
	
	
	<% } %>

	<html:hidden property="idx" value="<%=row.getIdx()%>" />
	<html:hidden property="rowMode"  value="<%=row.getRowMode()%>"/>

	</logic:iterate>

</table>

</html:form>
